package pikes.ecma;

public class ExpressionStatement extends PrintableSourceElement implements Statement {

	private IExpression expression = null;

	public ExpressionStatement(final IExpression expression) {
		this.expression = expression;
	}

	public void visit(final SyntaxTreeVisitor syntaxTreeVisitor) throws EcmaSyntaxVisitingException {
		expression.visit(syntaxTreeVisitor);
		syntaxTreeVisitor.endOfStatement();
	}

	@Override
	public boolean equals(final Object obj) {
		if (obj instanceof ExpressionStatement) {
			ExpressionStatement thatExpressionStatement = (ExpressionStatement) obj;
			return expression.equals(thatExpressionStatement.expression);
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return expression.hashCode();
	}

}
